package com.control;


import com.alibaba.fastjson.JSON;
import com.entity.DemoData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/cache")
public class CacheController {


    @Autowired
    StringRedisTemplate stringRedisTemplate ;

    @Autowired
    RedisTemplate redisTemplate ;
    @RequestMapping("/save")
    public void compareInfo(HttpServletRequest request){

        String address = request.getParameter("address");
        stringRedisTemplate.opsForValue().set("address",address);

        DemoData demoData=new DemoData();
        demoData.setSname("崔凯");
        demoData.setSno(11);
        System.out.println(JSON.toJSONString(demoData));
        stringRedisTemplate.opsForValue().set("name",JSON.toJSONString(demoData));

    }

}
